﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SqlSugar;

namespace Crossroad.System.Admin.Model
{
    ///<summary>
    ///组织架构
    ///</summary>
    [SugarTable("admin_organization")]
    public partial class Organization : ModelContext
    {
        public Organization()
        {
            LoadDefVal();
        }
        public Organization(bool loadDef)
        {
            if (loadDef)
                LoadDefVal();
        }

        private void LoadDefVal()
        {
            this.propertyId = Convert.ToInt32("0");
            this.createTime = Convert.ToInt32("0");
            this.sort = Convert.ToInt32("99");
            this.creatorId = Convert.ToInt32("0");
        }

        /// <summary>
        /// Desc:id
        /// Default:
        /// Nullable:False
        /// </summary>           
        [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
        public int id { get; set; }

        /// <summary>
        /// Desc:层级id列表
        /// Default:
        /// Nullable:True
        /// </summary>           
        [SugarColumn(ColumnName = "layer_list")]
        public string layerList { get; set; }

        /// <summary>
        /// Desc:层级深度
        /// Default:
        /// Nullable:True
        /// </summary>           
        [SugarColumn(ColumnName = "layer_num")]
        public int? layerNum { get; set; }

        /// <summary>
        /// Desc:名称
        /// Default:
        /// Nullable:False
        /// </summary>           
        public string name { get; set; }

        /// <summary>
        /// Desc:上级id
        /// Default:
        /// Nullable:True
        /// </summary>           
        [SugarColumn(ColumnName = "parent_id")]
        public int? parentId { get; set; }

        /// <summary>
        /// Desc:属性id:0.默认,1.部门
        /// Default:0
        /// Nullable:True
        /// </summary>           
        [SugarColumn(ColumnName = "property_id")]
        public int? propertyId { get; set; }

        /// <summary>
        /// Desc:创建时间
        /// Default:0
        /// Nullable:True
        /// </summary>           
        [SugarColumn(ColumnName = "create_time")]
        public int? createTime { get; set; }

        /// <summary>
        /// Desc:排序
        /// Default:99
        /// Nullable:True
        /// </summary>           
        public int? sort { get; set; }

        /// <summary>
        /// Desc:创建人
        /// Default:0
        /// Nullable:True
        /// </summary>           
        [SugarColumn(ColumnName = "creator_id")]
        public int? creatorId { get; set; }

        /// <summary>
        /// 角色id
        /// </summary>
        [SugarColumn(ColumnName = "role_id")]
        public int? roleId { get; set; }

        #region 扩展属性

        /// <summary>
        /// 子节点
        /// </summary>
        [SugarColumn(IsIgnore = true)]
        public List<Organization> children { get; set; }

        [SugarColumn(IsIgnore = true)]
         public string label
         {
             get { return name; }
             set { }
         }

        [SugarColumn(IsIgnore = true)]
         public int value
         {
             get { return id; }
             set { }
         }

        /// <summary>
        /// 上级名称
        /// </summary>
        [SugarColumn(IsIgnore = true)]
         public string parentName { get; set; }

         #endregion
    }
}
